﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Quanlybanhang_pro202.Module
{
    class Taikhoan
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["quanlybanhang"].ToString());
        SqlCommand cmd;
        SqlDataAdapter sqlDA;
        DataSet ds;
        DataTable dt;
        public DataSet Login(string tendangnhap,string matkhau)
        {
        try
        {
        conn.Open();
            cmd = new SqlCommand("select * from taikhoan where tendangnhap = '"+tendangnhap+"' and matkhau = '"+matkhau+"'",conn);
            sqlDA = new SqlDataAdapter();
            ds = new DataSet();
            sqlDA.SelectCommand = cmd;
            sqlDA.Fill(ds,"login");
            return ds;
        }
            catch
            {
            throw;
            }
        }
        public DataSet GetAllUser()

        {
            try
            {
                conn.Open();
                cmd = new SqlCommand("select * from taikhoan", conn);
                sqlDA = new SqlDataAdapter();
                ds = new DataSet();
                sqlDA.SelectCommand = cmd;
                sqlDA.Fill(ds, "taikhoan");
                return ds;
            }
            catch
            {
                throw;
            }
        }

        public DataSet GetMember()
        {
            try
            {
                conn.Open();
                cmd = new SqlCommand("select * from taikhoan where manhom = 2", conn);
                sqlDA = new SqlDataAdapter();
                ds = new DataSet();
                sqlDA.SelectCommand = cmd;
                sqlDA.Fill(ds, "thungan");
                return ds;
            }
            catch
            {
                throw;
            }
        }
    }
}
